import Vue from 'vue'
import App from './App.vue'

//请求数据配置
import VueResource from 'vue-resource'
Vue.use(VueResource)

import VueRouter from 'vue-router'
Vue.use(VueRouter)

//1、创建组件文件
import Start from './components/Start.vue'
import Home from './components/Home.vue'
import Hot from './components/Hot.vue'
import Order from './components/Order.vue'
import Pcontent from './components/Pcontent.vue'
import Search from './components/Search.vue'
import Cart from './components/Cart.vue'


//2、配置路由
const routes=[
  {path:'/start',component:Start},
  {path:'/home',component:Home},
  {path:'/hot',component:Hot},
  {path:'/order',component:Order},
 /* {path:'/pcontent/:id',component:Pcontent}, 动态路由*/
  {path:'/pcontent',component:Pcontent},
  {path:'/search',component:Search},
  {path:'/cart',component:Cart},
  {path:'*',redirect:'/start'}
]


//3\实例化

const router=new VueRouter({
   routes//(缩写)相当于routes:routes
})

//4、挂载

new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

//5、需要<router-view></router-view>放在根组件里
